/**
 * Factory class that creates an instance of a map object.
 * By submitting a provider name, the user can define the provider of the map service.
 * 
 * @author Kim Pommert
 * @version %I%, %G%
 */
qx.Class.define("qooxdoosample.cocktail.maps.MapFactory",
{
	// The class only has a static method, so it will be declared as static
	type: "static",
	
	statics:
	{
		
		/**
		 * Creates an instance of a map object.
		 * When the provider parameter is set, the user can decide 
		 * which implementation of the map interface will be returned.
		 * 
		 * The map has to be deployed in a valid <div> container of the DOM Structure.
		 * Therefore the ID of that container has to be submitted during the instantiation of the map.
		 * 
		 * @param mapContainerId {String} The ID of the <div> container the map will be deployed to
		 * @param provider		 {qooxdoosample.cocktail.maps.provider.MapProvider?} defines the provider of the map service
		 * @return 				 {qooxdoosample.cocktail.maps.IMap} The specified IMap object
		 */
		createMap: function(mapContainerId, provider)
		{
			/*
			 * This sample project only contains dynamic maps.
			 * Therefore the requests will be forwarded to the createDynamicMap
			 * function of this factory class.
			 */
			return this.createDynamicMap(mapContainerId, provider);
		},
		
		/**
		 * Creates an instance of a dynamic map object.
		 * When the provider parameter is set, the user can decide 
		 * which implementation of the map interface will be returned.
		 * 
		 * The map has to be deployed in a valid <div> container of the DOM Structure.
		 * Therefore the ID of that container has to be submitted during the instantiation of the map.
		 * 
		 * @param mapContainerId {String} The ID of the <div> container the map will be deployed to
		 * @param provider		 {qooxdoosample.cocktail.maps.provider.DynamicMapProvider?} defines the provider of the map service
		 * @return 				 {qooxdoosample.cocktail.maps.IDynamicMap} The specified IDynamicMap object
		 */
		createDynamicMap: function(mapContainerId, provider)
		{
			if(provider != null) // user defined a specific provider
			{
				if(provider == qooxdoosample.cocktail.maps.provider.MapProvider.GOOGLE)
					return new qooxdoosample.google.maps.GMapsWrapper(mapContainerId);
				else if(provider == qooxdoosample.cocktail.maps.provider.MapProvider.BING)
					return new qooxdoosample.microsoft.bing.maps.BMapsWrapper(mapContainerId);
			} 
			else // return default provider
			{
				return new qooxdoosample.google.maps.GMapsWrapper(mapContainerId);
			}
		}
	}
	
});